home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / management / HotspotCompilation.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  4.2 KB  |  151 lines

  1. package sun.management;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.ListIterator;
  6. import java.util.Map;
  7. import java.util.TreeMap;
  8. import sun.management.counter.Counter;
  9. import sun.management.counter.LongCounter;
  10. import sun.management.counter.StringCounter;
  11.  
  12. class HotspotCompilation implements HotspotCompilationMBean {
  13.    private VMManagement jvm;
  14.    private static final String JAVA_CI = "java.ci.";
  15.    private static final String COM_SUN_CI = "com.sun.ci.";
  16.    private static final String SUN_CI = "sun.ci.";
  17.    private static final String CI_COUNTER_NAME_PATTERN = "java.ci.|com.sun.ci.|sun.ci.";
  18.    private LongCounter compilerThreads;
  19.    private LongCounter totalCompiles;
  20.    private LongCounter totalBailouts;
  21.    private LongCounter totalInvalidates;
  22.    private LongCounter nmethodCodeSize;
  23.    private LongCounter nmethodSize;
  24.    private StringCounter lastMethod;
  25.    private LongCounter lastSize;
  26.    private LongCounter lastType;
  27.    private StringCounter lastFailedMethod;
  28.    private LongCounter lastFailedType;
  29.    private StringCounter lastInvalidatedMethod;
  30.    private LongCounter lastInvalidatedType;
  31.    private CompilerThreadInfo[] threads;
  32.    private int numActiveThreads;
  33.    private Map counters;
  34.  
  35.    HotspotCompilation(VMManagement var1) {
  36.       this.jvm = var1;
  37.       this.initCompilerCounters();
  38.    }
  39.  
  40.    private Counter lookup(String var1) {
  41.       Object var2 = null;
  42.       Counter var3;
  43.       if ((var3 = (Counter)this.counters.get("sun.ci." + var1)) != null) {
  44.          return var3;
  45.       } else if ((var3 = (Counter)this.counters.get("com.sun.ci." + var1)) != null) {
  46.          return var3;
  47.       } else if ((var3 = (Counter)this.counters.get("java.ci." + var1)) != null) {
  48.          return var3;
  49.       } else {
  50.          throw new InternalError("Counter " + var1 + " does not exist");
  51.       }
  52.    }
  53.  
  54.    private void initCompilerCounters() {
  55.       ListIterator var1 = this.getInternalCompilerCounters().listIterator();
  56.       this.counters = new TreeMap();
  57.  
  58.       while(var1.hasNext()) {
  59.          Counter var2 = (Counter)var1.next();
  60.          this.counters.put(var2.getName(), var2);
  61.       }
  62.  
  63.       this.compilerThreads = (LongCounter)this.lookup("threads");
  64.       this.totalCompiles = (LongCounter)this.lookup("totalCompiles");
  65.       this.totalBailouts = (LongCounter)this.lookup("totalBailouts");
  66.       this.totalInvalidates = (LongCounter)this.lookup("totalInvalidates");
  67.       this.nmethodCodeSize = (LongCounter)this.lookup("nmethodCodeSize");
  68.       this.nmethodSize = (LongCounter)this.lookup("nmethodSize");
  69.       this.lastMethod = (StringCounter)this.lookup("lastMethod");
  70.       this.lastSize = (LongCounter)this.lookup("lastSize");
  71.       this.lastType = (LongCounter)this.lookup("lastType");
  72.       this.lastFailedMethod = (StringCounter)this.lookup("lastFailedMethod");
  73.       this.lastFailedType = (LongCounter)this.lookup("lastFailedType");
  74.       this.lastInvalidatedMethod = (StringCounter)this.lookup("lastInvalidatedMethod");
  75.       this.lastInvalidatedType = (LongCounter)this.lookup("lastInvalidatedType");
  76.       this.numActiveThreads = (int)this.compilerThreads.longValue();
  77.       this.threads = new CompilerThreadInfo[this.numActiveThreads + 1];
  78.       if (this.counters.containsKey("sun.ci.adapterThread.compiles")) {
  79.          this.threads[0] = new CompilerThreadInfo(this, "adapterThread", 0);
  80.          ++this.numActiveThreads;
  81.       } else {
  82.          this.threads[0] = null;
  83.       }
  84.  
  85.       for(int var3 = 1; var3 < this.threads.length; ++var3) {
  86.          this.threads[var3] = new CompilerThreadInfo(this, "compilerThread", var3 - 1);
  87.       }
  88.  
  89.    }
  90.  
  91.    public int getCompilerThreadCount() {
  92.       return this.numActiveThreads;
  93.    }
  94.  
  95.    public long getTotalCompileCount() {
  96.       return this.totalCompiles.longValue();
  97.    }
  98.  
  99.    public long getBailoutCompileCount() {
  100.       return this.totalBailouts.longValue();
  101.    }
  102.  
  103.    public long getInvalidatedCompileCount() {
  104.       return this.totalInvalidates.longValue();
  105.    }
  106.  
  107.    public long getCompiledMethodCodeSize() {
  108.       return this.nmethodCodeSize.longValue();
  109.    }
  110.  
  111.    public long getCompiledMethodSize() {
  112.       return this.nmethodSize.longValue();
  113.    }
  114.  
  115.    public List getCompilerThreadStats() {
  116.       ArrayList var1 = new ArrayList(this.threads.length);
  117.       int var2 = 0;
  118.       if (this.threads[0] == null) {
  119.          var2 = 1;
  120.       }
  121.  
  122.       while(var2 < this.threads.length) {
  123.          var1.add(this.threads[var2].getCompilerThreadStat());
  124.          ++var2;
  125.       }
  126.  
  127.       return var1;
  128.    }
  129.  
  130.    public MethodInfo getLastCompile() {
  131.       return new MethodInfo(this.lastMethod.stringValue(), (long)((int)this.lastType.longValue()), (int)this.lastSize.longValue());
  132.    }
  133.  
  134.    public MethodInfo getFailedCompile() {
  135.       return new MethodInfo(this.lastFailedMethod.stringValue(), (long)((int)this.lastFailedType.longValue()), -1);
  136.    }
  137.  
  138.    public MethodInfo getInvalidatedCompile() {
  139.       return new MethodInfo(this.lastInvalidatedMethod.stringValue(), (long)((int)this.lastInvalidatedType.longValue()), -1);
  140.    }
  141.  
  142.    public List getInternalCompilerCounters() {
  143.       return this.jvm.getInternalCounters("java.ci.|com.sun.ci.|sun.ci.");
  144.    }
  145.  
  146.    // $FF: synthetic method
  147.    static Counter access$000(HotspotCompilation var0, String var1) {
  148.       return var0.lookup(var1);
  149.    }
  150. }
  151.